<!DOCTYPE html> 
<html>
<head>
<meta charset="utf-8">
<title>phonegap_device_network_notification01</title>
<link href="../jquery.mobile-1.3.2.css" rel="stylesheet" type="text/css"/>
<script src="../jquery.js" type="text/javascript"></script>
<script src="../jquery.mobile-1.3.2.js" type="text/javascript"></script>
<script src="../cordova.js" type="text/javascript"></script>
<style>
    #supportedMode{
        width: 288px; height: 100px;position:relative;border:1px solid #b8b8b8;
    }
    #message{
        width: 288px; height: 100px;position:relative;border:1px solid #b8b8b8;
    }
    #audiocontainer{
        width: 288px; height: 100px; position:relative;border:1px solid #b8b8b8;
    }
</style>
<script type="text/javascript" charset="utf-8">
    $(document).ready(function(){
                      
      	document.addEventListener("deviceready",onDeviceReady,false); 
      
    });
    function onDeviceReady(){
        
        $('#captureAudioBtn').click(function(){ 
        	navigator.device.capture.captureAudio(captureSuccess, captureError, {limit:2,duration:5});
        	
        })
    }   
    //成功
    function captureSuccess(mediaFiles){
  		var i;
  		for(i=0;i<mediaFiles.length;i++){
  			var fullPath= mediaFiles[i].fullPath;
  			var name= mediaFiles[i].name  			
  			/*
  			 * console.log('第'+i+'个音频');
  			console.log('fullPath-->'+fullPath);
  			console.log('name-->'+name);
  			console.log("type--->" + mediaFiles[i].type);
 			console.log("lastModifiedDate--->" + mediaFiles[i].lastModifiedDate);
 			console.log("size--->" + mediaFiles[i].size);
  			*/
 			$("#message").append ("filename:"+name +"path:"+fullPath+"<br/>");              
        	$("#audiocontainer").append("<audio autoplay=true controls='controls' src='"+fullPath+"' >your browder doesn't support audio tag</audio>"); 
  			
  		}
  	}
  	
    //失败的回调函数
    function captureError(error) {
        var msg = 'An error occurred during capture: ' + error.code;
        navigator.notification.alert(msg, null, 'Uh oh!');
    }
  

    </script>
</head> 
<body>
<div data-role="page">
		<div data-role="header">
			<h1>phonegap100.com</h1>
		</div>
		 <div data-role="content" >
            <a data-role="button" id="captureAudioBtn" >Capture Audio</a>                 
            <div id="audiocontainer"></div>
            <div id="message"></div>       
        </div>  
		<div data-role="footer">
			<h4>phonegap中文网</h4>
		</div>
</div>

</body>
</html>
